package com.jt.demo101Post;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;


@Controller  //MVC专业扫描注解
@RequestMapping("/a")
@ResponseBody
@CrossOrigin
class demo101 {

    @RequestMapping("/must")   //路径与方法

    public void  name(){
        System.out.println("We must stay true to ourselves.\n" +
                "忠于自我，顺心而为。");
    }


    @RequestMapping("/Astatic")
    public aDD Astatic(aDD aDD){
        aDD.setAge(22);
        aDD.setName("女神");
        aDD.setSex("女");
        return aDD;
    }


    @RequestMapping("/string")
    public String[] strings(String[] string){
        return string;
    }

    @GetMapping("/string1")
    public String strings1(String[] string){
        return Arrays.toString(string);
    }

    @GetMapping("/path/{a}/{name}")   //localhost:8080/a/path/女/女生
    public aDD pathVariable (@PathVariable String a,
                             @PathVariable String name){
        aDD aa= new aDD();
        aa.setSex(a);
        aa.setName(name);
        return aa;
    }

    @GetMapping("/f")
    public String promise(){
        return "坚持！";
    }

    @GetMapping("/axios/getByid")
    public String promise1(Integer id){
        return "返回id为"+id;
    }

    @GetMapping("/axios1/findUser1")
    public aDD user1(aDD aDD){
        return aDD;
    }


    @GetMapping("/axios2/result2/{sex}/{name}/{age}")
    public aDD rest(aDD aDD){
        return aDD;
    }

    @GetMapping("/axios3/result3/{sex}/{name}/{age}")
    public aDD rest1(aDD aDD){
        return aDD;
    }

}







































class aDD{
    private String name;
    private String sex;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}